package com.trace.meat.controller;

import com.trace.meat.entity.AdminAcct;
import com.trace.meat.entity.Butcher;
import com.trace.meat.service.ButcherService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (Butcher)表控制层
 *
 * @author makejava
 * @since 2021-06-19 11:17:25
 */
@RestController
@RequestMapping("butcher")
public class ButcherController {
    /**
     * 服务对象
     */
    @Resource
    private ButcherService butcherService;
    /**
     * 新增牲畜经营者数据
     *
     * @param bname 牲畜经营者名字
     * @param  eid 企业id
     * @return 单条数据
     */
    //http://127.0.0.1:11451/butcher/insertOne?bname=lk5j&eid=1
    @GetMapping("insertOne")
    public Butcher insert(String bname, Integer eid) {
        Butcher butcher=new Butcher();
        butcher.setBname(bname);
        butcher.setEid(eid);
        return this.butcherService.insert(butcher);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param bid 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Butcher selectOne(Integer bid) {
        return this.butcherService.queryById(bid);
    }
    /**
     * 通过主键删除数据
     *
     * @param bid 主键
     * @return 是否成功
     */
    @GetMapping("deleteOne")
    public boolean deleteById(Integer bid) {
        return this.butcherService.deleteById(bid);
    }
    /**
     * 修改数据
     */
    //http://127.0.0.1:11451/butcher/updateOne?bid=3&bname=khhj&eid=1
    @GetMapping("updateOne")
    public Butcher update(Integer bid, String bname, Integer eid) {
        Butcher butcher=new Butcher();
        butcher.setBid(bid);
        butcher.setBname(bname);
        butcher.setEid(eid);
        return this.butcherService.update(butcher);
    }
}
